package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

public class NavService {
    /**
     * 封装导航数据
     *
     * @return
     */
    public NavModel[] getNavModels() {
//        数组的赋值
//        NavModel[] navModels = {null, null,null,null};//数组的静态定义
        NavModel[] navModels = new NavModel[6];//数组的动态定义
//        NavModel navModel = new NavModel();
//        navModel.setHref("1");
//        navModel.setTitle("1");
//        navModels[0] = navModel;
//        NavModel navModel1 = new NavModel();
//        navModel1.setHref("2");
//        navModel1.setTitle("2");
//        navModels[1] = navModel1;
//        System.out.println(navModels[4].getHref());
        NavDao navDao = new NavDao();
        for (int i = 0; i < navModels.length; i++) {
            NavModel navModel = new NavModel();
            navModel.setTitle(navDao.titles[i]);
            navModel.setHref(navDao.hrefs[i]);
            navModels[i] = navModel;
        }
        return navModels;
    }

    public static void main(String[] args) {
        new NavService().getNavModels();
    }
}
